package com.fsm.system.controller;

import com.fsm.common.log.config.LogData;
import com.fsm.common.log.entity.dto.OperationEnum;
import com.fsm.common.log.entity.dto.SystemTypeEnum;
import com.fsm.common.tools.Result.Result;
import com.fsm.system.entity.dto.LoginDto;
import com.fsm.system.service.LoginService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Tag(name = "登录控制接口")
@RequestMapping("/loginIn")
public class LoginController {
    @Autowired
    private LoginService loginService;

    /**
     * 系统用户登录接口
     *
     * @param
     * @return
     */
    @LogData(value = "系统用户登录接口",operation = OperationEnum.LOGIN,systemTypeEnum = SystemTypeEnum.BACKEND)
    @PostMapping("loginIn")
    @Operation(summary="系统用户登录接口",description="系统用户登录接口")
    public Result loginIn(@RequestBody LoginDto loginDto) throws Exception{
        return loginService.loginIn(loginDto);
    }

    /**
     * 系统用户登录登出
     *
     * @param
     * @return
     */
    @LogData(value = "系统用户登录登出",operation = OperationEnum.EXIT,systemTypeEnum = SystemTypeEnum.BACKEND)
    @GetMapping("loginOut")
    @Operation(summary="系统用户登录登出",description="系统用户登录登出")
    public Result loginOut() throws Exception{
        return loginService.loginOut();
    }

    /**
     * 生成验证码
     *
     * @param
     * @return
     */
    @GetMapping("createVerify")
    @Operation(summary="生成验证码",description="生成验证码")
    public Result createVerify() throws Exception{
        return loginService.createVerify();
    }
}
